﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IceCS.LinuxFilePermission.Core
{
    /// <summary>
    /// 组织角色
    /// </summary>
    public abstract class OrgRole
    {
        /// <summary>
        /// Id
        /// </summary>
        public virtual string Id { get; set; } = "undefined";
        /// <summary>
        /// 名称
        /// </summary>
        public virtual string Name { get; set; } = "undefined";

        /// <summary>
        /// 角色前缀
        /// </summary>
        public virtual string RolePrefix { get; } = "Role";


        private string _code;
        /// <summary>
        /// 编码
        /// </summary>
        public virtual string Code
        {
            get
            {
                if (_code == null)
                {
                    _code = this.RolePrefix + Id;
                }
                return _code;
            }
            set
            {
                if (!value.StartsWith(this.RolePrefix))
                {
                    _code = this.RolePrefix + value;
                }
                else
                {
                    _code = value;
                }
            }

        }
    }
}